package base.objectoriented;

interface Singer {
	public void sing();
	public void sleep();
	
}

interface Painter{
	public void paint();
	public void eat();
}

class Student implements Singer{
	private String name;
	Student(String name){
		this.name = name;
	}
	
	//实现接口的类必须要重写接口的抽象方法
	public void sing(){
		System.out.println("i am student"); 
	}
	
	public void sleep(){
		System.out.println("i am going to bed");
	}
	
	public void myname(){
		System.out.println("my name is:"+name);
	}
}

class Teacher implements Singer,Painter{
	private String Teacher; 
	public void sing(){
		System.out.println("teacher is singng");
	}
	
	public void sleep(){
		System.out.println("teacher is sleeping");
	}
	
	public void paint(){
		System.out.println("teacher is painting");
	}
	
	
	public void eat(){
		System.out.println("teacher is eating");
	}
}

//
public class TestInterface1 {
	public static void main(String[] args) {
		//定义接口引用，新建对象为接口的实现类，含有多态的概念
		Singer s1 = new Student("xiaohua");
		Painter p1 = new Teacher();
		//只能调用接口的实现后的方法，不能调用实现接口类自己的方法，结合内存图想想
		s1.sing();
		s1.sleep();
		
	}
}
